import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt(),q = in.nextInt();
        int[] array = new int[n+1];
        for(int i = 1; i <= n; i++) {
            array[i] = in.nextInt();
        }
        long[] dp = new long[n+1];
        for(int i = 1; i <= n; i++) {
            dp[i] = dp[i-1]+array[i];
        }
        while(q > 0) {
            int l = in.nextInt(),r = in.nextInt();
            System.out.println(dp[r] - dp[l-1]);
            q--;
        }
    }
}